#ifndef TILEMAP_H
#define TILEMAP_H

#include "Tile.h"

class Tilemap {
public:
	Tilemap(int width, int height);
	~Tilemap();
	void fill(Tile tile);
	void set(int x, int y, Tile tile);
	inline bool passable(int x, int y) const;
	inline const Tile& tile(int x, int y) const;
	inline int width() const;
	inline int height() const;
private:
	void allocate();
	void free();
private:
	Tile** m_tiles;
	int m_width, m_height;
};

inline bool Tilemap::passable(int x, int y) const {
	return !m_tiles[y][x].blocking;
}

inline const Tile& Tilemap::tile(int x, int y) const {
	return m_tiles[y][x];
}

inline int Tilemap::width() const {
	return m_width;
}

inline int Tilemap::height() const {
	return m_height;
}

#endif